//
//  Response.swift
//  icloud
//
//  Created by raymond on 2022/5/20.
//

import Foundation

struct Response<T: Codable>: Codable {
  var success: Bool
  var message: String
  var detailMessage: String?
  var code: Int
  var result: [T]
  var path: String?
  var method: String?
  var timestamp: UInt
  
  enum CodingKeys: String, CodingKey {
    case success
    case message
    case detailMessage
    case code
    case result
    case path
    case method
    case timestamp
  }
  
  /*
  init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
    let success = try container.decode(Bool.self, forKey: CodingKeys.success)
    let message = try container.decode(String.self, forKey: CodingKeys.message)
    let detailMessage = try container.decode(String.self, forKey: CodingKeys.detailMessage)
    let code = try container.decode(Int.self, forKey: CodingKeys.code)
    let result = try container.decode([T].self, forKey: CodingKeys.result)
    let path = try container.decode(String.self, forKey: CodingKeys.path)
    let method = try container.decode(String.self, forKey: CodingKeys.method)
    let timestamp = try container.decode(UInt.self, forKey: CodingKeys.timestamp)
    
    self.success = success
    self.message = message
    self.detailMessage = detailMessage
    self.code = code
    self.result = result
    self.path = path
    self.method = method
    self.timestamp = timestamp
  }*/
}
